/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.thienloc.omap.controller.services;

import com.thienloc.omap.entity.RequestQueue;
import com.thienloc.omap.session.RequestQueueFacade;
import com.thienloc.omap.util.Constant;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

/**
 *
 * @author GiangLT
 */
@ManagedBean
@ViewScoped
public class TipConfigBean extends AbstractServiceConfigBean {

    @EJB
    private RequestQueueFacade requestQueueFacade;
    private List<String> mdnList;

    public List<String> getMdnList() {
        return mdnList;
    }

    public void setMdnList(List<String> mdnList) {
        this.mdnList = mdnList;
    }

    @Override
    protected void validateForm() throws Exception {
    }

    @Override
    protected Logger getLogger() {
        return LoggerFactory.getLogger(TipConfigBean.class);
    }

    @Override
    public void resetToCreateFormAction() throws Exception {
        super.resetToCreateFormAction();
        list = facade.findByServiceName(Constant.TIP_SERVICE_NAME, startViewDate, endViewDate);
        selected.setServiceName(Constant.TIP_SERVICE_NAME);
        edit = false;
        view = false;
    }

    public void findDeliveredSubscriber(String content) {
        List<RequestQueue> rqList = requestQueueFacade.findByResponseContent(content);
        mdnList = new ArrayList<String>(rqList.size());
        for (RequestQueue requestQueue : rqList) {
            mdnList.add(requestQueue.getMsisdn());
        }

    }
}
